package com.test.beanconfig.config;

import com.test.beanconfig.pojo.People;
import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
public class PeopleConfig {

    @ConditionalOnProperty(prefix = "people", name = "alive", havingValue = "true")
    @Bean(value = "peopleBean")
    public People getPeopleAlive() {
        return new People();
    }

    @ConditionalOnProperty(prefix = "people", name = "alive", havingValue = "false")
    @Bean(value = "peopleBean")
    public People getPeopleDied() {
        People people = new People();
        people.setOtherMsg("The people is died");
        return people;
    }
}
